package com.pepsico.introjava.labs;
import static org.junit.Assert.*;

import org.junit.Test;

import com.pepsico.introjava.exceptions.InvalidParameterException;
import com.pepsico.introjava.labs.Company;
import com.pepsico.introjava.labs.Employee;


public class CompanyTest
{
	@Test
	public void testDefaultCompany()
	{
		Company c = new Company("Pepsi");
		assertEquals ("Pepsi", c.getName());
	}
	
	@Test
	public void testHire()
	{
		Company c = new Company("Pepsi");
		Employee e1 = new Employee ("Fred", 100);
		Employee e2 = new Employee ("Wilma", 200);
	
		c.hire(e1);
		c.hire(e2);
		
		c.pay();
		
		assertEquals(100, e1.getYtdSalary(), .001);
		assertEquals(200, e2.getYtdSalary(), .001);
		
	}
	
	@Test
	public void testDownsize()
	{
		Company c = new Company("Pepsi");
		Employee e1 = new Employee ("Fred", 100);
		Employee e2 = new Employee ("Wilma", 200);
	
		c.hire(e1);
		c.hire(e2);

		c.downsize(2);
		float net = c.pay();
		
		assertEquals (0, net, .001);
	}

	@Test
	public void testSetName()
	{
		Company c = new Company("Pepsi");
		c.setName("Pepsico");
		assertEquals ("Pepsico", c.getName());
	}
	
	@Test
	public void testInvalidNullName()
	{
		try {
			Company c = new Company(null);
		}catch (InvalidParameterException e)
		{
			return;
		}
		fail();
	}
	
	@Test(expected=InvalidParameterException.class) 
	public void testInvalidName()
	{
		Company c = new Company("");
	}

}














